import 'package:boss/color_constant.dart';
import 'package:boss/textStyle/text_style.dart';
import 'package:boss/ui/page/analysis/page/analysisDetail/model/analysis_detail_type.dart';
import 'package:hi_common/hi_common.dart';
import 'package:flutter/material.dart';

class TableHeader extends StatelessWidget {
  final AnalysisDetailType type;
  const TableHeader(this.type);

  @override
  Widget build(BuildContext context) {
    return DefaultTextStyle(
      style: TextStyleConstant().normal_2_28,
      child: Container(
        color: ColorConstant.ffcc.withOpacity(0.1),
        height: 80.w,
        child: Row(
          children: <Widget>[
            if (type == AnalysisDetailType.takeoutSellSort)
              ..._buildTakeoutSellSort(),
            if (type == AnalysisDetailType.commodityCommissionSort)
              ..._buildCommodityCommissionSort(),
            if (type == AnalysisDetailType.book)
              ..._buildStaffBookList(),
          ],
        ),
      ),
    );
  }

  List<Widget> _buildTakeoutSellSort() {
    return [
      Expanded(
        child: Container(
          child: Text('时间'),
          alignment: Alignment.center,
        ),
      ),
      Expanded(
          child: Container(
            child: Text('类型'),
            alignment: Alignment.center,
          ),
        ),
      Expanded(
        child: Container(
          child: Text('金额(元)'),
          alignment: Alignment.center,
        ),
        flex: 2,
      ),
      Expanded(
        child: Container(
          child: Text('员工姓名'),
          alignment: Alignment.center,
        ),
        flex: 2,
      ),
      Expanded(
        child: Container(
          child: Text('状态'),
          alignment: Alignment.center,
        ),
      ),
    ];
  }

  List<Widget> _buildCommodityCommissionSort() {
    return [
      Expanded(
        child: Container(
          child: Text('时间'),
          alignment: Alignment.center,
        ),
      ),
      Expanded(
        child: Container(
          child: Text('金额(元)'),
          alignment: Alignment.center,
        ),
        flex: 2,
      ),
      Expanded(
        child: Container(
          child: Text('员工姓名'),
          alignment: Alignment.center,
        ),
        flex: 2,
      ),
      Expanded(
        child: Container(
          child: Text('状态'),
          alignment: Alignment.center,
        ),
      ),
    ];
  }

  List<Widget> _buildStaffBookList() {
    return [
      Expanded(
        child: Container(
          child: Text('员工姓名'),
          alignment: Alignment.center,
        ),
      ),
      Expanded(
        child: Container(
          child: Text('预定桌数'),
          alignment: Alignment.center,
        ),
      ),
      Expanded(
        child: Container(
          child: Text('提成金额'),
          alignment: Alignment.center,
        ),
      ),
    ];
  }
}
